<?php
/**
 * Created by JetBrains PhpStorm.
 * User: heimuya
 * Date: 14-1-26
 * Time: 下午1:33
 * 主页控制器类
 */
class IndexAction extends AdminAction{
	
	public function _initialize(){
		parent::_initialize();
		$this->assign('page', __CLASS__);
	}
    /**
     * 后台首页
     */
    public function index(){
    	$statistic = array();
		$statistic['single'] = D('Food')->count();
		
		//获取未过期的促销活动
		$where['stop_time'] = array('elt', time());
		$statistic['sale'] = D('Onsale')->where($where)->count();
		
		//获取店铺数
		$statistic['store']['direct'] = D('Store')->where('type="direct"')->count();
		$statistic['store']['all'] = D('Store')->count();
		
		//获取机台数
		$statistic['machine']['valid'] = D('Machine')->where('valid="y"')->count();
		$statistic['machine']['all'] = D('Machine')->count();
		
		$statistic['group'] = D('Group')->count();
		$statistic['headoffice'] = D('Headoffice')->count();
		$statistic['region'] = D('Region')->count();
		
		//获取机台数
		$statistic['user']['valid'] = D('User')->where('valid="y" and type="user"')->count();
		$statistic['user']['all'] = D('User')->where('type="user"')->count();
		
		$this->assign('statistic', $statistic);
        $this->display();
    }
}